package com.qipay.baas.mapper;

import static org.apache.ibatis.jdbc.SqlBuilder.BEGIN;
import static org.apache.ibatis.jdbc.SqlBuilder.INSERT_INTO;
import static org.apache.ibatis.jdbc.SqlBuilder.SET;
import static org.apache.ibatis.jdbc.SqlBuilder.SQL;
import static org.apache.ibatis.jdbc.SqlBuilder.UPDATE;
import static org.apache.ibatis.jdbc.SqlBuilder.VALUES;
import static org.apache.ibatis.jdbc.SqlBuilder.WHERE;

import com.qipay.baas.model.QipayTradlog;

public class QipayTradlogSqlProvider {

    public String insertSelective(QipayTradlog record) {
        BEGIN();
        INSERT_INTO("qipay_tradlog");
        
        if (record.getSpId() != null) {
            VALUES("sp_id", "#{spId,jdbcType=BIGINT}");
        }
        
        if (record.getChannelType() != null) {
            VALUES("channel_type", "#{channelType,jdbcType=TINYINT}");
        }
        
        if (record.getSpFeeRecharge() != null) {
            VALUES("sp_fee_recharge", "#{spFeeRecharge,jdbcType=DECIMAL}");
        }
        
        if (record.getQipayAmount() != null) {
            VALUES("qipay_amount", "#{qipayAmount,jdbcType=INTEGER}");
        }
        
        if (record.getSpAmount() != null) {
            VALUES("sp_amount", "#{spAmount,jdbcType=INTEGER}");
        }
        
        if (record.getTradeNo() != null) {
            VALUES("trade_no", "#{tradeNo,jdbcType=CHAR}");
        }
        
        if (record.getTotal() != null) {
            VALUES("total", "#{total,jdbcType=INTEGER}");
        }
        
        if (record.getRemark() != null) {
            VALUES("remark", "#{remark,jdbcType=VARCHAR}");
        }
        
        if (record.getCreateTime() != null) {
            VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}");
        }
        
        return SQL();
    }

    public String updateByPrimaryKeySelective(QipayTradlog record) {
        BEGIN();
        UPDATE("qipay_tradlog");
        
        if (record.getSpId() != null) {
            SET("sp_id = #{spId,jdbcType=BIGINT}");
        }
        
        if (record.getChannelType() != null) {
            SET("channel_type = #{channelType,jdbcType=TINYINT}");
        }
        
        if (record.getSpFeeRecharge() != null) {
            SET("sp_fee_recharge = #{spFeeRecharge,jdbcType=DECIMAL}");
        }
        
        if (record.getQipayAmount() != null) {
            SET("qipay_amount = #{qipayAmount,jdbcType=INTEGER}");
        }
        
        if (record.getSpAmount() != null) {
            SET("sp_amount = #{spAmount,jdbcType=INTEGER}");
        }
        
        if (record.getTradeNo() != null) {
            SET("trade_no = #{tradeNo,jdbcType=CHAR}");
        }
        
        if (record.getTotal() != null) {
            SET("total = #{total,jdbcType=INTEGER}");
        }
        
        if (record.getRemark() != null) {
            SET("remark = #{remark,jdbcType=VARCHAR}");
        }
        
        if (record.getCreateTime() != null) {
            SET("create_time = #{createTime,jdbcType=TIMESTAMP}");
        }
        
        WHERE("id = #{id,jdbcType=BIGINT}");
        
        return SQL();
    }
}